﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using System.Threading.Tasks;
using Clothing.Base.Framework.Model;
using Clothing.Base.Framework.Connect;


namespace Clothing.Base.Framework.Data
{
    class DataProvider
    {

        private DataProvider() { }
        private static DataProvider instance = null;
        public static DataProvider Instance()
        {
            if (instance == null)
            {
                instance = new DataProvider();
            }
            return instance;
        }
        #region Constant Value
        private const string PROC_SELECT_POSTIONINFO = "proc_select_postionInfo";
        #endregion
        public List<PostionInfo> GetPostionInfo()
        {
            List<PostionInfo> postionInfos = new List<PostionInfo>();
            using (SqlDataReader reader = SqlHelper.ExecuteReader(PROC_SELECT_POSTIONINFO, SqlConnect.BaseConstr, CommandType.StoredProcedure))
            {
                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        PostionInfo posInfo = new PostionInfo();
                        posInfo.Id = reader.GetInt32(0);
                        posInfo.PositionName = reader.GetString(1);
                        posInfo.EnglishName = reader.GetString(2);
                        postionInfos.Add(posInfo);
                    }
                }
                return postionInfos;
            }
        }
    }
}
